﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace W7Toshil.Controls
{
    public class DateTextBox : TextBox 
    {
        private readonly Key[] numeric = new Key[] {Key.Back, Key.NumPad0, Key.NumPad1, Key.NumPad2, Key.NumPad3, Key.NumPad4,
        Key.NumPad5, Key.NumPad6, Key.NumPad7, Key.NumPad8, Key.NumPad9, Key.Divide };

        public DateTextBox()
        {
            this.InputScope = new InputScope();
            this.InputScope.Names.Add(new InputScopeName() { NameValue = InputScopeNameValue.Date });
        }

        protected override void OnKeyDown(KeyEventArgs e)
        {
            

                if (Array.IndexOf(numeric, e.Key) == -1)
                {
                    e.Handled = true;
                }


            
            base.OnKeyDown(e); // important, if not called the back button is not handled

            
        }
    }
}
